package com.admin.education.dataTransferObject.categorys.Mapper;

import com.admin.education.dataTransferObject.categorys.CategoryTemplateTransfer;
import com.admin.education.dataTransferObject.categorys.CategorysTransfer;
import com.admin.education.dataTransferObject.categorys.Request.CreateCategoryRequest;
import com.admin.education.dataTransferObject.categorys.Request.UpdateCategoryRequest;
import com.admin.education.models.Categorys;
import com.admin.education.models.Templates;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import javax.persistence.MapsId;
import java.util.List;

@Mapper
public abstract class CategoryMapper {
    @Mappings({})
    public abstract CategorysTransfer mapFrom(Categorys categorys);

    @Mappings({})
    public abstract List<CategorysTransfer> mapFrom(List<Categorys> categorys);

    @Mappings({})
    public abstract CategoryTemplateTransfer mapFrom(Templates templates);

    @Mappings({})
    public abstract List<CategoryTemplateTransfer> mapTemplateFrom(List<Templates> templates);

    @Mappings({})
    public abstract Categorys mapFrom(CreateCategoryRequest createCategoryRequest);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "templates", ignore = true),
            @Mapping(target = "valid", ignore = true)
    })
    public abstract Categorys mapFrom(UpdateCategoryRequest updateCategoryRequest, @MappingTarget Categorys categorys);

}
